/**
 * <p>Title: ItemCatServiceImpl.java</p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2017</p>
 * @author lijian
 * @date 2017年3月12日下午9:09:42
 * @version 1.0
 */
package com.lijian.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lijian.common.easyui.tree.EasyuiTreeNode;
import com.lijian.mapper.TbItemCatMapper;
import com.lijian.pojo.TbItemCat;
import com.lijian.pojo.TbItemCatExample;
import com.lijian.service.ItemCatService;

/**
 * 菜单树
 * <p>Title: ItemCatServiceImpl.java</p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2017</p>
 * @author lijian
 * @date 2017年3月12日下午9:09:42
 * @version 1.0
 */
@Service
public class ItemCatServiceImpl implements ItemCatService {

	@Autowired
	private TbItemCatMapper itemCatMapper;
	/**
	 * <p>Title: getItemCatList</p>
	 * <p>Description: </p>
	 * @param parentId
	 * @return
	 * @see com.lijian.service.ItemCatService#getItemCatList(long)
	 */
	@Override
	public List<EasyuiTreeNode> getItemCatList(long parentId) {
		TbItemCatExample example=new TbItemCatExample();
		example.createCriteria().andParentIdEqualTo(parentId);
		List<TbItemCat> list=itemCatMapper.selectByExample(example);
		List<EasyuiTreeNode> resultList=new ArrayList<EasyuiTreeNode>();
		for(TbItemCat item:list){
			resultList.add(new EasyuiTreeNode(item.getId(), item.getName(), item.getIsParent()?"closed":"open"));
		}
		return resultList;
	}

}
